<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<!--
    2. 语法糖  class  extends  super  set  get 属性的私有化   构造器
-->

<script>

    /*
    *   js中创建对象
    *    1. 字面量
    *    2. new Object()
    *    3. 构造函数
    *    4. class
    * */

    let obj = {
        name: 'lisi',
        age: 20
    }

    console.log(obj)
    let obj2 = new Object()

    console.log(obj2)
    // 构造函数
    function  Student(name,age){
        this.name = name
        this.age = age
    }

    Student.prototype.sex = '男'
    Student.prototype.study = function (){
        console.log("学习")
    }

    let  obj3 = new Student('lisi',20)
    console.log(obj3)
    console.log(obj3.name)
    console.log(obj3.age)
    console.log(obj3.sex)
    obj3.study()

    console.log("-------------------------------------------------")
    class User{

        constructor(name,age,sex) {
            this.name = name
            this.sex = sex
            this.age = age
        }
    }

    const  user = new User('张三',20,'男')
    console.log(user)
    console.log(user.name)
    console.log(user.age)
    console.log(user.sex)


</script>
</body>
</html>